package edu.gatech.cs2340.bytebankers.model;

import java.util.Random;

import java.awt.Point;
import java.io.Serializable;

public class RiverCrossing extends Location implements Serializable {

	private String name;
	private int lat,lon, distNext, xCor, yCor;
	private Location nextLocation;
	private Point point;
	
	public RiverCrossing(String n, Location next, int dist, int latitude, 
			int longitude) {
		super(n, next, dist, latitude, longitude, false);
		this.name = n;
		this.nextLocation = next;
		this.distNext = dist;
		this.lat = latitude;
		this.lon = longitude;
	}
	
	public int getLat() {
		return lat;
	}

	public int getLon() {
		return lon;
	}
	
	public Location getNextLocation() {
		return nextLocation;
	}


	public int getDistNext() {
		return distNext;
	}


	public Point getCoordinates(){
		Point coordinates = new Point();
		coordinates.x = lat;
		coordinates.y = lon;
		return coordinates;
	}

	public int getDistanceToNext()
	{
		return distNext;
	}
	
	public void setDistNext(int distance){
		distNext = distance;
		
	}
	
	public String getName(){
		return name;
	}

	
	int minDepth;
	int maxDepth;
	int depth;
	boolean hasFerry;
	
	public RiverCrossing(String n, Location next, boolean s, boolean r, int dist,
			int latitude, int longitude) {
		super(n, next, dist, latitude, longitude, false);
	}
	
	public void setDepthRange(int min, int max) {
		minDepth = min;
		maxDepth = max;
	}
	
	public void generateDepth() {
		Random rand = new Random();
		depth = rand.nextInt(maxDepth + 1 - minDepth) + minDepth;
	}
	
	public int getDepth() {
		return depth;
	}
	
	public boolean hasFerry() {
		return hasFerry;
	}
	
	public boolean crossWasSuccessful(int crossType) {
		Random rand = new Random();
		
		switch(crossType) {
		case 1:
			return true;
		case 2:
			return (0==rand.nextInt(4)); 
		case 3:
			return (0==rand.nextInt(2));
		}
		
		return false;
		
	}

	
}
